﻿Imports System.Data.SqlClient

Public Class FormStoreeditor

    Private Sub btnOK_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnOK.Click

        Cmd.Parameters("@StoreName") = Me.txtStoreName.Text
        Cmd.Parameters("@StoreId") = Me.txtStoreId.Text
        
        If Me.txtStoreId.Text = "" Then
            Cmd.ExecuteNonQuery("INSERT INTO Store VALUES(@StoreName,1);")
        Else
            Cmd.Parameters("@StoreId") = txtStoreId.Text
            Cmd.ExecuteNonQuery("UPDATE Store SET StoreName=@StoreName  WHERE StoreId=@StoreId")
        End If

        Me.DialogResult = Windows.Forms.DialogResult.OK
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub
End Class